using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class doeMap : EntityTypeConfiguration<doe>
    {
        public doeMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.ACCT)
                .HasMaxLength(40);

            this.Property(t => t.DESC)
                .HasMaxLength(30);

            this.Property(t => t.CURSYMB)
                .HasMaxLength(5);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.doe_PartyID)
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("doe");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.CURR).HasColumnName("CURR");
            this.Property(t => t.CURSYMB).HasColumnName("CURSYMB");
            this.Property(t => t.RATE).HasColumnName("RATE");
            this.Property(t => t.ACCTBAL).HasColumnName("ACCTBAL");
            this.Property(t => t.CURBAL).HasColumnName("CURBAL");
            this.Property(t => t.NEWBAL).HasColumnName("NEWBAL");
            this.Property(t => t.DOEVAL).HasColumnName("DOEVAL");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.doe_CstCtrID).HasColumnName("doe_CstCtrID");
            this.Property(t => t.doe_PartyID).HasColumnName("doe_PartyID");

            // Relationships
            this.HasOptional(t => t.Acct1)
                .WithMany(t => t.does)
                .HasForeignKey(d => d.ACCT);
            this.HasOptional(t => t.currency)
                .WithMany(t => t.does)
                .HasForeignKey(d => d.CURR);

        }
    }
}
